package com.yidu.StockControl.service.impl;


import com.yidu.StockControl.entity.SecurityInventors;
import com.yidu.StockControl.mapper.SecurityInventorsMapper;
import com.yidu.StockControl.service.SecurityInventorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 证券库存     证券库存        证券库存
 */
@Service
public class SecurityInventorsServiceImpl implements SecurityInventorsService {

    @Resource
    SecurityInventorsMapper securityInventorsMapper;


    @Override
    public List<SecurityInventors> selectSecurityInventors(String securityInventorsTime, String securityPrice, int page, int limit) {
        System.out.println("查询");
        Map map = new HashMap();
        map.put("strWhere",buildWhere(securityInventorsTime,securityPrice));
        map.put("page",(page-1)*limit);
        map.put("limit",page*limit);
        return securityInventorsMapper.selectSecurityInventors(map);
    }
    public String buildWhere (String securityInventorsTime,String securityPrice) {
        StringBuffer strWhere = new StringBuffer();

        if (securityInventorsTime!=null && !securityInventorsTime.equals("")){
            strWhere.append(" and securityInventorsTime like '%" + securityInventorsTime +"%'" );
        }
        if (securityPrice!=null && !securityPrice.equals("")){
            strWhere.append(" and securityPrice like '%" + securityPrice +"%'" );
        }
        return strWhere.toString();
    }

    @Override
    public int selectCashInventoryCount() {
        return securityInventorsMapper.selectSecurityInventorsCount();
    }

    @Override
    public int insertSecurityInventors(SecurityInventors securityInventors) {
        return securityInventorsMapper.insertSecurityInventors(securityInventors);
    }

    @Override
    public void updateSecurityInventors(SecurityInventors securityInventors) {
        securityInventorsMapper.updateSecurityInventors(securityInventors);
    }

    @Override
    public void deleteSecurityInventors(String securityInventorsId) {
        securityInventorsMapper.deleteSecurityInventors(securityInventorsId);
    }




}
